/******************************************************************************
 * Copyright (C) 2015  671643387@qq.com
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *****************************************************************************/

#include "NodeCpp/Util/Option.h"
#include <cassert>
#include "NodeCpp/Macros.h"

namespace NodeCpp {
namespace Util {

    Option::Option(const std::string& _Name, const std::string& _ShortName, const std::string& _Description)
        : Name_(_Name)
        , ShortName_(_ShortName)
        , Description_(_Description)
        , Value_()
        
        , HasArg_(false)
        , Required_(false)
        , Valid_(false)
    {

    }

    Option::~Option(void)
    {

    }

    bool Option::MatchName(const std::string& _Name)
    {
        if (_Name.size() <= 2) {
            return false;
        }

        if (_Name[0] != '-' && _Name[1] != '-') {
            return false;
        }
        return (Name_.compare(&_Name[2]) == 0);
    }

    bool Option::MatchShortName(const std::string& _ShortName)
    {
        if (_ShortName.size() <= 1) {
            return false;
        }

        if (_ShortName[0] != '-') {
            return false;
        }
        return (ShortName_.compare(&_ShortName[1]) == 0);
    }

}}